#ifndef _ITM_H
#define _ITM_H
#ifdef  __cplusplus
    extern "C" {
#endif
/*-----------------------------------------------------------------------
|                               Includes                                |
-----------------------------------------------------------------------*/
#include "main.h"
#include <stdbool.h>
/*-----------------------------------------------------------------------
|                                define                                 |
-----------------------------------------------------------------------*/
#ifndef UINT32_MAX
#define UINT32_MAX 0xFFFFFFFF
#endif
#ifdef DWT_BASE
uint32_t DWT_Init(void);

extern void dwt_access(bool ena);
/* Max Count Time */
static inline uint32_t DWT_MAX_SEC(void)
{
  return (UINT32_MAX / SystemCoreClock);
};

static inline uint32_t DWT_MAX_MSEC(void)
{
  return (UINT32_MAX / (SystemCoreClock / 1000));
};

static inline uint32_t DWT_MAX_USEC(void)
{
  return (UINT32_MAX / (SystemCoreClock / 1000000));
};

static inline uint32_t DWT_GetTicks(void)
{
  return (DWT->CYCCNT);
};

#define DWT_TickToUS(ticks) (((float)ticks)/(SystemCoreClock/1E6))

#endif
/*-----------------------------------------------------------------------
|                             API FUNCTION                              |
-----------------------------------------------------------------------*/
void DWT_delay_us(uint32_t us);
void DWT_delay_ms(uint32_t ms);
inline void DWT_delay_Tick(uint32_t tick);
float DWT_Time_Measure(uint32_t *old_counter);
#ifdef __cplusplus
}
#endif
#endif
